package com.woniu.auth.controller;


import com.ruoyi.common.core.domain.AjaxResult;
import com.woniu.auth.dto.UserDto;
import com.woniu.auth.dto.WebUserDto;
import com.woniu.auth.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginController {

    @Autowired
    LoginService loginService;

    @RequestMapping("/login")
    public AjaxResult login(@RequestBody UserDto userDto) {
        System.out.println(userDto);
        String token = loginService.login(userDto);


      return AjaxResult.success("ok",token);
    }

    @RequestMapping("web/login")
    public AjaxResult webLogin(@RequestBody WebUserDto webUserDto){
        System.out.println(webUserDto);
        String jwt = loginService.webLogin(webUserDto);
        return AjaxResult.success("ok",jwt);
    }
}
